#include <stdio.h>

typedef struct 
{
    int ID;
    char Name[20];
    float Score;
}STUDENT;


int main(int argc, char const *argv[])
{
    if( argc != 2)
    {
        printf("Pls input: ./a.out <dst file name> \n");
        return -1;
    }

    FILE *fp = fopen(argv[1], "w");
    if ( NULL == fp)
    {
        printf("Fail to fopen %s\n", argv[1]);
        return -1;
    }
    printf("Success to fopen %s\n", argv[1]);

    char strBuff[10] = {"ABCDE"};
    size_t ret1 = fwrite( strBuff, sizeof(strBuff), 1, fp );
    printf("Write to file %s total %lu items \n", argv[1], ret1 );
    
    STUDENT stu[2] = {{1,"Zhang", 90.2},{2, "Li", 80.8}};
    size_t ret2 = fwrite(stu, sizeof(STUDENT), 2, fp);
    printf("Write to file %s total %lu items \n", argv[1], ret2 );

    fclose(fp);

    return 0;
}

/*
函数 fwrite
    可以操作文本或者二进制文件
*/